package com.example.myapplication.util;

import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.schedulers.Schedulers;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

public class HttpUtil {
    public static void sendOkHttpRequest(String address,okhttp3.Callback callback){
        OkHttpClient client=new OkHttpClient();
        Request request=new Request.Builder().url(address).build();
        client.newCall(request).enqueue(callback);
    }
    public static Observable<Response> request(String address) {
        OkHttpClient client = new OkHttpClient();
        Observable<Response> observable = Observable.fromCallable(() -> {
            Request request = new Request.Builder().url(address).build();

            return client.newCall(request).execute();
        }).subscribeOn(Schedulers.io());
        return observable;
    }
}

